package com.example.everying.model.entity.appeal;/*
 * 项目名称: everything
 * 文件名: AppealEvidence
 * 作者: 张泽阳
 * 日期: 2025/6/20
 * 描述:
 */

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;

@Data
@TableName("appeal_evidence")
public class AppealEvidence {
    @ApiModelProperty("申诉凭证id")
    @NotNull(message = "申诉凭证id不能为空")
    @TableId(type = IdType.ASSIGN_ID)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    @ApiModelProperty("申诉id")
    @NotNull(message = "申诉id不能为空")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long appealId;

    @ApiModelProperty("申诉凭证内容")
    @NotNull(message = "申诉凭证内容不能为空")
    private String content;

    @ApiModelProperty("凭证所属用户id")
    @NotNull(message = "申诉凭证所属用户id不能为空")
    private String userId;
    @ApiModelProperty("申诉凭证状态 （0：待审核；1：审核通过；2：撤销；3：失败）")
    @NotNull(message = "申诉凭证状态不能为空")
    private String evidenceStatus;

    @ApiModelProperty("凭证所属人类型（0：发布人；1：接单人；2：官方）")
    private String userType;

    @ApiModelProperty("凭证类型（0：申诉人凭证；1：被申诉人凭证）")
    private String evidenceType;

    @ApiModelProperty("修改人id")
    private String updateUser;

    @ApiModelProperty("凭证创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty("凭证更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @ApiModelProperty("申诉凭证图片")
    @NotNull(message = "申诉凭证图片不能为空")
    @TableField("picture_url")
    private String pictureUrlStr;

    @TableField(exist = false)
    private List<String> pictureUrl;

    public void setPictureUrl(List<String> pictureUrl) {
        this.pictureUrl = pictureUrl;
        if (pictureUrl != null){
            this.pictureUrlStr = String.join(",", pictureUrl);
        }

    }

    public List<String> getPictureUrl() {
        if (pictureUrl == null && pictureUrlStr != null) {
            pictureUrl = List.of(pictureUrlStr.split(","));
        }
        return pictureUrl;
    }



}
